package com.youth.msmservice.controller;

import com.youth.commonutils.R;
import com.youth.msmservice.service.MsmService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
//使用nginx是需要使用@CrossOrigin解决跨域问题的，现在使用gateway网关替代    /*解决跨域问题，也就是nginx跨域问题*/
@RequestMapping("/edumsm/msm")
@Api(description = "短信相关接口")
public class MsmApiController {

    @Autowired
    private MsmService msmService;

    @ApiOperation(value = "发送短信的方法用于登录操作")
    @PostMapping("/sendSms/{phone}")
    public R sendSms(@PathVariable String phone){
        boolean res = msmService.sendSms(phone);
        if(res==true){
            return R.ok();
        }
        return R.error().message("短信发送失败");
    }

    @ApiOperation(value = "提醒用户")
    @PostMapping("/sendSmsAnno/{phone}")
    public R sendSmsAnno(@PathVariable String phone){
        boolean res = msmService.sendSmsAnno(phone);
        if(res==true){
            return R.ok();
        }
        return R.error().message("短信发送失败");
    }


}